<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="search" placeholder="请输入">
  <script>
    const input = document.querySelector('input')

    /* 
    1.键盘事件：
    Keydown 键盘按下触发
    Keyup   键盘抬起触发
    input.addEventListener('keydown', function () {
      console.log(`键盘按下了`)
    })
    input.addEventListener('keyup', function () {
      console.log(`键盘弹起了`)
    })
   */

    // 2.用户输入文本事件
    input.addEventListener('input', function () {
      console.log('输入东西了')
      console.log(input.value.length)
    })
  </script>
</body>

</html>